﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Fynd.Hermes.Web.Objects;
using FyndSharp.BusinessLogic;

namespace Fynd.Hermes.Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                UserLogic theUserLogic = new DefaultLogicFactory().CreateLogic<UserLogic>(new AnonymousUser());
                UserInfomation theUser = theUserLogic.FetchUserBy(this.Login1.UserName, this.Login1.Password);
                if (null != theUser)
                {
                    Session.Add(Global.HttpSessionKeyUserId, theUser.Id);
                    e.Authenticated = true;
                }
                else
                {
                    e.Authenticated = false;
                }
            }
            catch
            {
                e.Authenticated = false;
            }
        }
    }
}